package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;
                                                                                            import com.ruoyi.common.utils.DateUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.ApplyAppListMapper;
import com.ruoyi.bizsys.domain.ApplyAppList;
import com.ruoyi.bizsys.service.IApplyAppListService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * appList绑定Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class ApplyAppListServiceImpl extends ServiceImpl<ApplyAppListMapper,ApplyAppList> implements IApplyAppListService {

    /**
     * 查询appList绑定
     *
     * @param id appList绑定ID
     * @return appList绑定
     */
    @Override
    public ApplyAppList selectApplyAppListById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询appList绑定列表
     *
     * @param applyAppList appList绑定
     * @return appList绑定
     */
    @Override
    public List<ApplyAppList> selectApplyAppListList(ApplyAppList applyAppList) {
        return this.list(new QueryWrapper<>(applyAppList).last("order by id desc"));
    }

    /**
     * 新增appList绑定
     *
     * @param applyAppList appList绑定
     * @return 结果
     */
            @Override
    public int insertApplyAppList(ApplyAppList applyAppList) {
                                                                                                                                                            applyAppList.setCreateTime(DateUtils.getNowDate());
                            return baseMapper.insert(applyAppList);
    }

    /**
     * 修改appList绑定
     *
     * @param applyAppList appList绑定
     * @return 结果
     */
            @Override
    public int updateApplyAppList(ApplyAppList applyAppList) {
                                                                                                                                                            return baseMapper.updateById(applyAppList);
    }

    /**
     * 批量删除appList绑定
     *
     * @param ids 需要删除的appList绑定ID
     * @return 结果
     */
            @Override
    public int deleteApplyAppListByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除appList绑定信息
     *
     * @param id appList绑定ID
     * @return 结果
     */
    @Override
    public int deleteApplyAppListById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public List<Integer> getIdsByCustNo(String userId) {
        String[] split = baseMapper.getIdsByCustNo(userId).split(",");
        Integer[] ids = (Integer[]) ConvertUtils.convert(split,Integer.class);
        return Arrays.asList(ids);
    }

    @Override
    public String get7DaysAppList(String custNo) {
        return baseMapper.get7DaysAppList(custNo);
    }

    @Override
    public int selectApplistCount(String userId, String applyNo) {
        return baseMapper.selectApplistCount(userId, applyNo);
    }

}
